/**
 */
package org.xtext.example.mydsl.myDsl.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.xtext.example.mydsl.myDsl.Door;
import org.xtext.example.mydsl.myDsl.MyDslPackage;
import org.xtext.example.mydsl.myDsl.Point;
import org.xtext.example.mydsl.myDsl.Wall;
import org.xtext.example.mydsl.myDsl.Window;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Wall</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.WallImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.WallImpl#getStart <em>Start</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.WallImpl#getEnd <em>End</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.WallImpl#getHeight <em>Height</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.WallImpl#getTexture <em>Texture</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.WallImpl#getDoor <em>Door</em>}</li>
 *   <li>{@link org.xtext.example.mydsl.myDsl.impl.WallImpl#getWindows <em>Windows</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class WallImpl extends MinimalEObjectImpl.Container implements Wall
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getStart() <em>Start</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getStart()
   * @generated
   * @ordered
   */
  protected Point start;

  /**
   * The cached value of the '{@link #getEnd() <em>End</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEnd()
   * @generated
   * @ordered
   */
  protected Point end;

  /**
   * The default value of the '{@link #getHeight() <em>Height</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHeight()
   * @generated
   * @ordered
   */
  protected static final String HEIGHT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getHeight() <em>Height</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHeight()
   * @generated
   * @ordered
   */
  protected String height = HEIGHT_EDEFAULT;

  /**
   * The default value of the '{@link #getTexture() <em>Texture</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTexture()
   * @generated
   * @ordered
   */
  protected static final String TEXTURE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getTexture() <em>Texture</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTexture()
   * @generated
   * @ordered
   */
  protected String texture = TEXTURE_EDEFAULT;

  /**
   * The cached value of the '{@link #getDoor() <em>Door</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDoor()
   * @generated
   * @ordered
   */
  protected Door door;

  /**
   * The cached value of the '{@link #getWindows() <em>Windows</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getWindows()
   * @generated
   * @ordered
   */
  protected EList<Window> windows;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected WallImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MyDslPackage.Literals.WALL;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.WALL__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Point getStart()
  {
    return start;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetStart(Point newStart, NotificationChain msgs)
  {
    Point oldStart = start;
    start = newStart;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.WALL__START, oldStart, newStart);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setStart(Point newStart)
  {
    if (newStart != start)
    {
      NotificationChain msgs = null;
      if (start != null)
        msgs = ((InternalEObject)start).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.WALL__START, null, msgs);
      if (newStart != null)
        msgs = ((InternalEObject)newStart).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.WALL__START, null, msgs);
      msgs = basicSetStart(newStart, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.WALL__START, newStart, newStart));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Point getEnd()
  {
    return end;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetEnd(Point newEnd, NotificationChain msgs)
  {
    Point oldEnd = end;
    end = newEnd;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.WALL__END, oldEnd, newEnd);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setEnd(Point newEnd)
  {
    if (newEnd != end)
    {
      NotificationChain msgs = null;
      if (end != null)
        msgs = ((InternalEObject)end).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.WALL__END, null, msgs);
      if (newEnd != null)
        msgs = ((InternalEObject)newEnd).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.WALL__END, null, msgs);
      msgs = basicSetEnd(newEnd, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.WALL__END, newEnd, newEnd));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getHeight()
  {
    return height;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setHeight(String newHeight)
  {
    String oldHeight = height;
    height = newHeight;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.WALL__HEIGHT, oldHeight, height));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getTexture()
  {
    return texture;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTexture(String newTexture)
  {
    String oldTexture = texture;
    texture = newTexture;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.WALL__TEXTURE, oldTexture, texture));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Door getDoor()
  {
    return door;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetDoor(Door newDoor, NotificationChain msgs)
  {
    Door oldDoor = door;
    door = newDoor;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MyDslPackage.WALL__DOOR, oldDoor, newDoor);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDoor(Door newDoor)
  {
    if (newDoor != door)
    {
      NotificationChain msgs = null;
      if (door != null)
        msgs = ((InternalEObject)door).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.WALL__DOOR, null, msgs);
      if (newDoor != null)
        msgs = ((InternalEObject)newDoor).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MyDslPackage.WALL__DOOR, null, msgs);
      msgs = basicSetDoor(newDoor, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MyDslPackage.WALL__DOOR, newDoor, newDoor));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Window> getWindows()
  {
    if (windows == null)
    {
      windows = new EObjectContainmentEList<Window>(Window.class, this, MyDslPackage.WALL__WINDOWS);
    }
    return windows;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MyDslPackage.WALL__START:
        return basicSetStart(null, msgs);
      case MyDslPackage.WALL__END:
        return basicSetEnd(null, msgs);
      case MyDslPackage.WALL__DOOR:
        return basicSetDoor(null, msgs);
      case MyDslPackage.WALL__WINDOWS:
        return ((InternalEList<?>)getWindows()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MyDslPackage.WALL__NAME:
        return getName();
      case MyDslPackage.WALL__START:
        return getStart();
      case MyDslPackage.WALL__END:
        return getEnd();
      case MyDslPackage.WALL__HEIGHT:
        return getHeight();
      case MyDslPackage.WALL__TEXTURE:
        return getTexture();
      case MyDslPackage.WALL__DOOR:
        return getDoor();
      case MyDslPackage.WALL__WINDOWS:
        return getWindows();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MyDslPackage.WALL__NAME:
        setName((String)newValue);
        return;
      case MyDslPackage.WALL__START:
        setStart((Point)newValue);
        return;
      case MyDslPackage.WALL__END:
        setEnd((Point)newValue);
        return;
      case MyDslPackage.WALL__HEIGHT:
        setHeight((String)newValue);
        return;
      case MyDslPackage.WALL__TEXTURE:
        setTexture((String)newValue);
        return;
      case MyDslPackage.WALL__DOOR:
        setDoor((Door)newValue);
        return;
      case MyDslPackage.WALL__WINDOWS:
        getWindows().clear();
        getWindows().addAll((Collection<? extends Window>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.WALL__NAME:
        setName(NAME_EDEFAULT);
        return;
      case MyDslPackage.WALL__START:
        setStart((Point)null);
        return;
      case MyDslPackage.WALL__END:
        setEnd((Point)null);
        return;
      case MyDslPackage.WALL__HEIGHT:
        setHeight(HEIGHT_EDEFAULT);
        return;
      case MyDslPackage.WALL__TEXTURE:
        setTexture(TEXTURE_EDEFAULT);
        return;
      case MyDslPackage.WALL__DOOR:
        setDoor((Door)null);
        return;
      case MyDslPackage.WALL__WINDOWS:
        getWindows().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MyDslPackage.WALL__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case MyDslPackage.WALL__START:
        return start != null;
      case MyDslPackage.WALL__END:
        return end != null;
      case MyDslPackage.WALL__HEIGHT:
        return HEIGHT_EDEFAULT == null ? height != null : !HEIGHT_EDEFAULT.equals(height);
      case MyDslPackage.WALL__TEXTURE:
        return TEXTURE_EDEFAULT == null ? texture != null : !TEXTURE_EDEFAULT.equals(texture);
      case MyDslPackage.WALL__DOOR:
        return door != null;
      case MyDslPackage.WALL__WINDOWS:
        return windows != null && !windows.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(", height: ");
    result.append(height);
    result.append(", texture: ");
    result.append(texture);
    result.append(')');
    return result.toString();
  }

} //WallImpl
